Chapter 8\EmployeeDataIsland2.htm

<HTML>
<HEAD>
<TITLE>Employees</TITLE>

<SCRIPT LANGUAGE=javascript>
<!--

function button1_onclick() 
{
    var xmlEmp = 
		employees.documentElement.childNodes.item
			( select1.selectedIndex );

    var xmlPos = xmlEmp.childNodes.item( 1 );
    var xmlPhone = xmlEmp.childNodes.item( 2 );

    position.innerText = xmlPos.text;
    phone.innerText = xmlPhone.childNodes.item(0).text;
}
//-->
</SCRIPT>
</HEAD>

<XML ID=employees>
<employees>
    <employee>
        <name>
            <first>John</first>
            <last>Doe</last>
        </name>
        <position>Programmer</position>
        <phone>
            <main>(714) 555-1000</main>
        </phone>
    </employee>
    <employee>
        <name>
            <first>Jane</first>
            <last>Doe</last>
        </name>
        <position>Systems Analyst</position>
        <phone>
            <main>(714) 555-2000</main>
        </phone>
    </employee>
</employees>
</XML>

<BODY>

<!-- Put the employee names within 
	 the combo box.
-->
<H2>Select an employee</H2>
<SELECT id=select1 name=select1>
<SCRIPT LANGUAGE=javascript>
<!--
    var xmlRoot = employees.documentElement;
    var intTotal = xmlRoot.childNodes.length;
    var xmlEmp;
    var intCount;

    for ( intCount = 0;
	  intCount < intTotal;
	  intCount++ )
    {
        xmlEmp = xmlRoot.childNodes.item( intCount );
        document.write( "<OPTION>" );
        document.write( 
			xmlEmp.childNodes.item( 0 ).text );

        document.write( "</OPTION>" );
    }
//-->
</SCRIPT>
</SELECT>

<INPUT type="button" value="Go get it!" id=button1 name=button1 LANGUAGE=javascript onclick="return button1_onclick()">

<P>
<TABLE WIDTH=100%>
    <TR><TD WIDTH=10%><B>Position:</B>
    <TD><SPAN ID=position></SPAN>
    <TR><TD><B>Phone:</B>
    <TD><SPAN ID=phone></SPAN>
</TABLE>

</BODY>
</HTML>